<!doctype html>
<html>
  <head>
    <title>XMLHttpRequest: send() - data argument</title>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="/following::ol/li[4]" />
  </head>
  <body>
    <div id="log"></div>
    <script>
      function requestCharset(input, charset, contentType) {
        test(function() {
          var client = new XMLHttpRequest();
          client.open("POST", "print-content-type.cgi", false);
          if (contentType)
            client.setRequestHeader("Content-Type", contentType);
          client.send(input);
          assert_true(client.responseText.indexOf("charset=" + charset) >= 0);
        }, document.title + " (" + input + " requested with charset=" + charset + ")")
      }
      requestCharset(1, "UTF-8");
      requestCharset(1, "UTF-8", "application/javascript;charset=us-ascii");
      requestCharset(new URLSearchParams([[1, 2], [3, 4]]), "UTF-8");
      requestCharset(new URLSearchParams([[1, 2], [3, 4]]), "UTF-8", "text/javascript;charset=us-ascii");
    </script>
  </body>
</html>
